package com.bdqn.zhang.dao;

import com.bdqn.zhang.entity.SysUser;
import org.springframework.orm.hibernate5.support.HibernateDaoSupport;

import java.util.List;

public class SysUserDaoImpl extends HibernateDaoSupport implements SysUserDao{

    @Override
    public void addSysUser(SysUser sysUser) {
        this.getHibernateTemplate().save(sysUser);
    }

    @Override
    public SysUser findUser(SysUser sysUser) {
        List<SysUser> userList = (List<SysUser>)this.getHibernateTemplate().findByValueBean("from SysUser u where u.name=:name and u.password=:password",sysUser);
        if(userList.size() > 0 && userList != null){
            return userList.get(0);
        } else {
            return null;
        }
    }
}
